package com.example.server.service.impl;

import com.example.server.entity.Bookshelf;
import com.example.server.mapper.BookshelfMapper;
import com.example.server.service.BookshelfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookshelfServiceImpl implements BookshelfService {

    @Autowired
    private BookshelfMapper bookshelfMapper;

    @Override
    public List<Bookshelf> getBookshelfByUserId(int iduser) {
        return bookshelfMapper.getBookshelfByUserId(iduser);
    }

    @Override
    public void addBookToBookshelf(Bookshelf bookshelf) {
        bookshelfMapper.addBookToBookshelf(bookshelf);
    }

    @Override
    public void removeBookFromBookshelf(int iduser, int idbook) {
        bookshelfMapper.removeBookFromBookshelf(iduser, idbook);
    }

    @Override
    public boolean isBookInBookshelf(int iduser, int idbook) {
        return bookshelfMapper.isBookInBookshelf(iduser, idbook) > 0;
    }
}
